package io.a.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.a.dto.PageDTO;
import io.a.entity.User;
import io.a.mapper.UserMapper;
import io.a.query.UserQuery;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("user")
@RestController
public class UserController {

    @Resource
    private UserMapper userMapper;

    public PageDTO<User> queryUsersPage(UserQuery userQuery) {
        Page<User> userPage = userMapper.selectPage(new Page<>(userQuery.getPageNo(), userQuery.getPageSize()), new LambdaQueryWrapper<>());
        return new PageDTO<>(userPage.getTotal(), userPage.getPages(), userPage.getRecords());
    }
}
